<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/5/30
 * Time: 15:13
 */
namespace App\Modules\User\Services;

use App\Modules\User\Models\UserAverageRecommend;
use App\Modules\User\Models\UserRecommend;
use Illuminate\Database\Eloquent\Model;
use DB;
use Redis;

class UserRecommendAllService extends Model{


    /**
     * 自荐表被查看次数
     */
    static function RecommendAllReadTimes(){
        $readTime = Redis::hget('average_recommend_info:', 'readTimes');

        if ($readTime === null ) {
            $readTime = UserAverageRecommend::RecommendAllReadTimes();
            Redis::hset('average_recommend_info:', 'readTimes',$readTime);
        }

        return $readTime;
    }

    /**
     * 用户自荐表数
     */
    static function RecommendAllTimes(){
        $recommendTimes = Redis::hget('average_recommend_info:', 'recommendTimes');

        if ($recommendTimes === null ) {
            $recommendTimes = UserAverageRecommend::RecommendAllTimes();
            Redis::hset('average_recommend_info:', 'recommendTimes',$recommendTimes);
        }

        return $recommendTimes;
    }
    /**
     * 用户自荐成功次数
     */
    static function RecommendAllSuccessTimes(){
        $RecommendSuccessTimes = Redis::hget('average_recommend_info:', 'recommendSuccessTimes');

        if ($RecommendSuccessTimes === null ) {
            $RecommendSuccessTimes = UserAverageRecommend::RecommendAllSuccessTimes();
            Redis::hset('average_recommend_info:', 'recommendSuccessTimes',$RecommendSuccessTimes);
        }

        return $RecommendSuccessTimes;
    }

    /**
     * 获取自荐用户数
     */
    static function RecommendAllUserNum(){
        $RecommendSuccessTimes = Redis::hget('average_recommend_info:', 'recommendAllUserNum');

        if ($RecommendSuccessTimes === null ) {
            $RecommendSuccessTimes = UserAverageRecommend::RecommendUserNum();
            Redis::hset('average_recommend_info:', 'recommendAllUserNum',$RecommendSuccessTimes);
        }

        return $RecommendSuccessTimes;
    }

}